package com.yjd.bi.user.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import com.yjd.comm.base.dao.impl.BaseDaoImpl;
import com.yjd.bi.user.model.UserAreaStatisticsModel;
import com.yjd.bi.user.model.UserSexStatisticsModel;
import com.yjd.bi.user.model.UserAgeStatisticsModel;
import com.yjd.bi.user.model.UserStatisticsConditionModel;
import com.yjd.bi.user.dao.IUserStatisticsConditionDao;

/**
 * <b>description</b>：每日汇总统计数据访问层 <br>
 * <b>time</b>：2016-04-26 16:48:56 <br>
 * <b>author</b>： carl
 */
@Component("userStatisticsConditionDao")
public class UserStatisticsConditionDaoImpl extends BaseDaoImpl implements
		IUserStatisticsConditionDao {

	private static final String SQLMAPNAMESPACE = UserStatisticsConditionModel.class
			.getName();
	private static final String PKNAME = "id";

	@Override
	public String getPrimaryKeyName() {
		return PKNAME;
	}

	@Override
	public String getSqlmapNamespace() {
		return SQLMAPNAMESPACE;
	}

	@Override
	public double userSexSum(Map<String, Object> paramMap, boolean b) {
		Object myObject = this.getSqlMap(b).queryForObject(
				this.getStatement("userSexSum"), paramMap);
		if (myObject != null) {
			return Double.parseDouble(myObject.toString());
		}
		return 0.d;
	}

	@Override
	public UserSexStatisticsModel getSummaryModel(Map paramMap, boolean write)
			throws Exception {

		return (UserSexStatisticsModel) this.getSqlMap(write).queryForObject(
				this.getStatement("getSummaryModel"), paramMap);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAgeStatisticsModel> getInvestNumByAge(boolean b)
			throws Exception {
		return (List<UserAgeStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getInvestNumByAge"));

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAgeStatisticsModel> getRechargeNumByAge(boolean b)
			throws Exception {
		  
		return (List<UserAgeStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getRechargeNumByAge"));
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAgeStatisticsModel> getLoginNumByAge(boolean b)
			throws Exception {
		return (List<UserAgeStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getLoginNumByAge"));

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAgeStatisticsModel> getRegisterNumByAge(boolean b)
			throws Exception {
		return (List<UserAgeStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getRegisterNumByAge"));

	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAreaStatisticsModel> getInvestNumByArea(boolean b)
			throws Exception {
		return (List<UserAreaStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getInvestNumByArea"));
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAreaStatisticsModel> getRechargeNumByArea(boolean b)
			throws Exception {
		return (List<UserAreaStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getRechargeNumByArea"));
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<UserAreaStatisticsModel> getRegisterNumByArea(boolean b)
			throws Exception {
		return (List<UserAreaStatisticsModel>)this.getSqlMap(b).queryForList(this.getStatement("getRegisterNumByArea"));

	}

	@Override
	public Integer getSummary(Map<String, Object> paramMap) throws Exception {
		return (Integer) this.getSqlMap(false).queryForObject(
				getStatement("getSummary"), paramMap);
	}
	
}
